home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programmer Power Tools
/
Programmer Power Tools.iso
/
progjrn
/
pj_6_6.arc
/
CCODE.ARC
/
DOBENCH.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-09-02
|
2KB
|
71 lines
#include "bench.h"
int argc; char ** argv;
common_header() {
printf("Code Benchmark Iters Time\n");
printf("--------------------------- ------- -------\n");
}
common_trailer() {
printf("\nYou can execute only a subset of the benchmarks by placing the Code name(s)\n");
printf("of the desired benchmark(s) on the command line when executing this program.\n");
#if defined(AIA)
printf("This program courtesy of MetaWare and A.I. Architects.\n");
#elif defined(IGC)
printf("This program courtesy of MetaWare and Intelligent Graphics Corp.\n");
#else /* Default: */
printf("This program courtesy of MetaWare and Phar Lap.\n");
#endif
}
int Should_do_bench(bname) char *bname; {
/* If argc > 1, then do only a benchmark that appears in the argument list */
if (argc > 1) {
int i;
for (i = 1; i < argc; i++)
if (strcmp(argv[i],bname) == 0) return 1;
return 0;
}
else return 1;
}
/*
DoBench - Do a benchmark
*/
long DoBench(bname, strp, liters, funcp, initfuncp, EOL)
char *bname;
char *strp; /* Pointer to benchmark name */
long liters; /* Number of iterations */
int (*funcp)(); /* Pointer to benchmark function */
int (*initfuncp)(); /* Pointer to benchmark function */
{
long stime; /* Start time */
long etime; /* End time */
long time; /* Elapse time */
int secs; /* Seconds */
int hunds; /* 1/100 seconds */
extern long clock();
long clock1;
if (Should_do_bench(bname)) {
printf("%4s %-22s %6d ", bname, strp, liters);
(*initfuncp)();
stime = clock();
(*funcp)();
clock1 = clock();
/* Loop until the clock rolls over, to reduce variation. */
while (clock() == clock1) ;
etime = clock();
time = etime - stime;
secs = time / 100;
hunds = time % 100;
printf("%4d.%02d secs%s", secs, hunds, EOL ? "\n" : "");
return time;
}
else return 0;
}